If we don't have a waypoint name, create one.
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Fri, 24 Sep 2004 16:23:11 +0000 (16:23 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Fri, 24 Sep 2004 16:23:11 +0000 (16:23 +0000)
gpsbabel/waypt.c

index 9b5aa9c050b01e28e7d75691c0087c1758e00ba9..fde54f87b344e3100183434402205c79278cdc5c 100644 (file)
@@ -74,21 +74,27 @@ void
 waypt_add(waypoint *wpt)
 {
        ENQUEUE_TAIL(&waypt_head, &wpt->Q);
+       waypt_ct++;
 
        /*
         * Some input may not have one or more of these types so we
         * try to be sure that we have these fields even if just by
         * copying them from elsewhere.
         */
+
        if (wpt->shortname == NULL) {
                if (wpt->description) {
                        wpt->shortname = xstrdup(wpt->description);
+               } else if (wpt->notes) {
+                       wpt->shortname = xstrdup(wpt->notes);
                } else {
-                       if (wpt->notes) {
-                               wpt->shortname = xstrdup(wpt->notes);
-                       }
+               /* Last ditch:  make up a name */
+                       char cbuf[10];
+                       snprintf(cbuf, sizeof(cbuf), "WPT%03d", waypt_ct);
+                       wpt->shortname = xstrdup(cbuf);
                }
        }
+
        if (wpt->description == NULL || strlen(wpt->description) == 0) {
                if (wpt->description)
                        xfree(wpt->description);
@@ -100,7 +106,6 @@ waypt_add(waypoint *wpt)
                        }
                }
        }
-       waypt_ct++;
 }
 
 void